const http = require("http");
const handleChannelRequest = require("./views/goods");
const handleGoodsRequest = require("./views/goods");
const handleUserRequest = require("./views/user");

const server = http.createServer(
    (req,res) => {
        res.setHeader("Content-Type","application/json;charset=utf8")
        switch (true) {
            case req.url.startsWith("/user/"):
                handleUserRequest(req,res)
                break;
        
            case req.url.startsWith("/channel/"):
                handleChannelRequest(req,res)
                break;
        
            case req.url.startsWith("/goods/"):
                handleGoodsRequest(req,res)
                break;
        
            default:
                res.end("404网页丢失...")
                break;
        }
    }
)

server.listen(8888,()=>console.log("server is listening at 8888"))